home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / skim-unix.txt < prev    next >
Internet Message Format  |  1994-07-05  |  4KB

  1. Date: Thu, 25 Nov 93 18:06:58 +1300
  2. From: Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>
  3. Subject: Update on info-mac uploads browser
  4.  
  5. This is a new version of skim.c, a C program to ease the process of  
  6. downloading programs listed in the info-mac digest.
  7.  
  8. The latest modifications allow the site to be changed to a mirror site, and  
  9. the directory accordingly. Thanks to Robert Watkins (bob@nutmeg.cs.ntu.edu.au)  
  10. for these additions!
  11.  
  12. -------------------------- CUT HERE ------------------------------------------
  13.  
  14. /* To compile this program, first modify the #defines. You have to choose the
  15.    local directory to be used and to set your e-mail address.
  16.    You'll also have to add the directory to look into at the mirror site
  17.  
  18.    Then compile with cc -o skim skim.c -lcurses -ltermcap 
  19.  
  20.  
  21.  
  22.    Original skim program by : 
  23.  
  24.  
  25.    Craig Nevill-Manning,            e-mail: cgn@waikato.ac.nz
  26.    Department of Computer Science,  phone:  +64 7 838 4021 (work)
  27.    University of Waikato,                   +64 7 838 4232 (home)
  28.    Private Bag 3105,                      
  29.  
  30.    Hamilton,
  31.    New Zealand. 
  32.  
  33.  
  34.    Enhanced (added automatic script creation) by : 
  35.  
  36.  
  37.    Francois Pottier                 e-mail: pottier@dmi.ens.fr
  38.  
  39.    Minorly enhanced (enabled defining of different directories for info-mac)  
  40. by:
  41.  
  42.    Robert Watkins                   e-mail: bob@nutmeg.it.ntu.edu.au
  43. */
  44.  
  45.  
  46. #define localDirectory   "~/Mac/NEW"
  47. #define siteName         "archie.au"
  48. #define emailAddress     "bob@nutmeg.ntu.edu.au"
  49. #define mirrorDir     "/micros/mac/info-mac"
  50. #include <stdio.h>
  51. #include <curses.h>
  52.  
  53. FILE *download;
  54.  
  55. main(argc, argv)
  56. int argc;
  57. char **argv;
  58. {
  59.   int i;
  60.  
  61.   initscr();
  62.   cbreak();
  63.   
  64.  
  65.  
  66.   download = fopen("download", "w");
  67.   fprintf(download, "%s\n\n%s%s\n%s%s%s\n%s%s\n%s\n",
  68.                     "#!/bin/csh -f",
  69.                     "cd ", localDirectory,
  70.                     "ftp -n ", siteName, " << EOF",
  71.                     "user anonymous ", emailAddress,
  72.                     "ascii");
  73.  
  74.   for (i = 1; i < argc; i ++)
  75.     skim(argv[i]);
  76.  
  77.   fprintf(download, "EOF\n");
  78.   fclose(download);
  79.  
  80.   (void) chmod ("download", 493);    /* octal 755, rwxr-xr-x */
  81.  
  82.   nocbreak();
  83.   endwin();
  84. }
  85.  
  86. skim(filename)
  87. char *filename;
  88. {
  89.   FILE *f;
  90.   char s[1000], name[1000], nameOnly[1000];
  91.   int ch, line;
  92. /* TEMP VARIABLE ADDED FOR MY HACK */
  93.   char temp[1000];
  94.  
  95.   f = fopen(filename, "r");
  96.  
  97.   if (f) {
  98.     
  99.  
  100.  
  101.     while (!feof(f)) {
  102.       do {
  103.     fgets(s, 1000, f);
  104.       } while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
  105.  
  106.       line = 0;
  107.  
  108.       name[0] = 0;
  109.  
  110.  
  111.       clear();
  112.       refresh();
  113.  
  114.       puts(filename);
  115.       while (!feof(f)) {
  116.     if (line ++ < LINES - 4)
  117.       printf("%s", s);
  118.     fgets(s, 1000, f);
  119.     if (strncmp(s, "[Archived as", 12) == 0) {
  120.       strcpy(name, &s[13]);
  121.       break;
  122.     }
  123.       }
  124.  
  125.       printf("%s", s);
  126.       
  127.  
  128.  
  129.       if (name[0]) {
  130.     printf("Get this? (y/n)");
  131.  
  132.     do
  133.       ch = getchar();
  134.     while (ch != 'y' && ch != 'n' && ch != 'q');
  135.  
  136.     if (ch == 'y') {
  137.       int i;
  138.  
  139. /* MY HACK FOR THIS THING */
  140.           if (strncmp(name,"/info-mac",9)==0) {
  141.             strcpy(temp,mirrorDir);
  142.             strcat(temp,&name[9]);
  143.             strcpy(name,temp);
  144.           }
  145.       for (i = strlen(name); i > 0 && name[i] != ';'; i --) ;
  146.       name[i] = 0;
  147.  
  148.           for (i = strlen(name); i > 0 && name[i] != '/'; i--) ;
  149.           strcpy(nameOnly, &name[i+1]);
  150.           name[i] = 0;
  151.  
  152.       fprintf(download, "cd %s\n", name);
  153.           fprintf(download, "get %s\n", nameOnly);
  154.     }
  155.     else if (ch == 'q') {
  156.       fclose(download);
  157.       nocbreak();
  158.       endwin();
  159.       exit(0);
  160.     }
  161.       }
  162.     }
  163.  
  164.     fclose(f);
  165.   }
  166. }
  167.  
  168.  
  169.  
  170.  
  171.  
  172.